/**
 * Created by seeker910 on 2014/8/28.
 * @description 组件名称命名约定：继承container组件，名称以ViewPart结尾;继承control组件，名称以Part结尾
 * 分组展示 ：上部图片新闻 + 下部列表组合
 */
Rsd.define('Rsd.hermit.sections.ListGroupViewPart', {
    extend: 'Rsd.container.Component',
    requires: [
        'Rsd.control.List'
    ],
    xtype: 'list-group-view',
     /**
     * @description 标识该组件是否允许编辑
     */
    domEditable:true,
     /**
     * @description true:表示只允许在模板中修改
     */
    editInMaster:false,
    height: 300, 
    width:'100%', 
    layout:'hbox',
    items:[ ],
    /*
     * */
    constructor: function ListGroupViewPart(config) {
        config = config || {};
        Rsd.apply(this, config);
    },
    /**
     * 
     */
    loadData:function loadData(data)
    {
        //console.log('list - group',data);
         if(!data)
         {
            return this;
         }
        if(!Rsd.isArray(data))
        {
            console.error('Rsd.hermit.sections.ListGroupViewPart.loadData()方法的data参数必须是数组');
            return this;
        }
        if(!data && this.dataSource == data)
        {
            return this;
        }
       
        this.dataSource = data || this.dataSource;
 
        this.removeAll();

        for(var i in this.dataSource )
        {
            var item = this.dataSource[i]
           
            var ctrl = Rsd.apply({ 
                xtype:'list',
                label:{content:'',position:'top',height:'40px',width:'100%'},
                flex:1,
                height:'100%',
                margin:'0 50 0 50',
               
            },item);
            
            ctrl = this.add(ctrl);  
            
            this.doLayout();
        }
       
        return this;
    }
    
});
